package com.ruoyi.datastatistics.mapper;

import com.ruoyi.common.core.domain.Parameter;
import com.ruoyi.datastatistics.domain.DataApp;
import com.ruoyi.datastatistics.domain.HomepageResult;

import com.ruoyi.datastatistics.domain.TestDataResult;
import com.ruoyi.system.api.domain.SysDept;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;
@Mapper
public interface HomepageMapper {
    public HomepageResult selecttotal(Parameter parameter);
    public List<Map<String,Object>> getnexttotalbyday(Parameter parameter);

    @Select(value = "SELECT DISTINCT testtime FROM ${TableName} WHERE idcard = #{idcard}")
    List<String> getTesttime(@Param("TableName") String TableName, @Param("idcard") String idcard);
    @Select(value = "SELECT zongheScore,heartrate,metval,ZFLJG_FAT_W FROM ${TableName} WHERE idcard = #{idcard} AND testtime = #{testtime}")
    List<Map<String, Object>> getNumtests(@Param("TableName") String TableName,@Param("idcard") String idcard,@Param("testtime") String testtime);

    @Select(value = "SELECT e.*,a.code,a.xingbie,b.zhibiaomingcheng,b.danwei,b.columncode,b.zhibiaofenlei,b.fenleicode FROM (	"
            + "		SELECT realname,sex,age,nation,mechanismname,testtime,testage,shengaoval,shengaoscore,shengaograde,shengaotime,shengaogps,"
            + "zuogaoval,zuogaoscore,zuogaograde,zuogaotime,zuogaogps,tizhongval,tizhongscore,tizhonggrade,tizhongtime,tizhonggps,tzzsval,tzzsscore,"
            + "tzzsgrade,tzzstime,tzzsgps,tzlval,tzlscore,tzlgrade,tzltime,tzlgps,xiongweival,xiongweiscore,xiongweigrade,xiongweitime,xiongweigps,yaoweival,"
            + "yaoweiscore,yaoweigrade,yaoweitime,yaoweigps,tunweival,tunweiscore,tunweigrade,tunweitime,tunweigps,fhlval,fhlscore,fhlgrade,fhltime,"
            + "fhlgps,glcval,glcscore,glcgrade,glctime,glcgps,lfzydgttval,lfzydgttscore,lfzydgttgrade,lfzydgtttime,lfzydgttgps,lfzydgttzval,lfzydgttztime,"
            + "lfzydgttyval,lfzydgttytime,ajxlval,ajxlscore,ajxlgrade,ajxltime,ajxlgps,wolival,woliscore,woligrade,wolitime,woligps,zongtiaoval,zongtiaoscore,"
            + "zongtiaograde,zongtiaotime,zongtiaogps,fwcval,fwcscore,fwcgrade,fwctime,fwcgps,gwcval,gwcscore,gwcgrade,gwctime,gwcgps,yfzywqzval,yfzywqzscore,"
            + "yfzywqzgrade,yfzywqztime,yfzywqzgps,zwtqqval,zwtqqscore,zwtqqgrade,zwtqqtime,zwtqqgps,bydjzlval,bydjzlscore,bydjzlgrade,bydjzltime,"
            + "bydjzlgps,xzfysval,xzfysscore,xzfysgrade,xzfystime,xzfysgps,beilival,beiliscore,beiligrade,beilitime,beiligps,ssmzzval,ssmzzscore,"
            + "ssmzzgrade,ssmzztime,ssmzzgps,ldtyval,ldtyscore,ldtygrade,ldtytime,ldtygps,sjlxtval,sjlxtscore,sjlxtgrade,sjlxttime,sjlxtgps,swmrzapval,"
            + "swmrzapscore,swmrzapgrade,swmrzaptime,swmrzapgps,zphmval,zphmscore,zphmgrade,zphmtime,zphmgps,zphmnb,zongheScore,zongheGrade,gps "
            + "FROM ${TableName} WHERE idcard = #{idcard} AND testtime = #{testtime}) e "
            + "		LEFT JOIN `x_zhibiaozuhe` a ON a.nianlingdizhi <= e.testage AND a.nianlinggaozhi > e.testage AND a.xingbie = IF(e.sex = '男','1','2')"
            + "		LEFT JOIN `x_zhibiaoxinxi` b ON a.code = b.code")
    List<Map<String, Object>> getTestCorporeityReport(@Param("TableName") String TableName,@Param("idcard") String idcard,@Param("testtime") String testtime);
    TestDataResult getTestData(@Param("tableName") String TableName, @Param("idcard") String idcard, @Param("testtime") String testtime);
    @Select(value = "SELECT A.remark AS pingjiayu,A.itemCode AS ceshizhibiao,zhibiaofenlei,fenleicode  FROM `indicatorevaluation` A "
            +" LEFT JOIN `t_zhibiaoxinxi` B ON A.itemCode = B.`code` "
            +" WHERE A.itemcode = #{indexcode} AND A.ageStart <= #{nianling} AND A.ageEnd > #{nianling} AND A.valueStart <= #{testvalue} AND A.valueEnd > #{testvalue} AND A.sex = #{sex}")
    Map<String, Object> GetNewDXpingjia(@Param("nianling") float nianling,@Param("indexcode") String indexcode,@Param("testvalue") String testvalue,@Param("sex") String sex);
    @Select(value = "SELECT * FROM `x_liliangsuzhipingjia` A WHERE A.`nianlingdizhi` <= #{nianling} AND A.`nianlinggaozhi` > #{nianling} AND A.defendizhi <= #{SumQuality} AND A.defengaozhi >= #{SumQuality}")
    Map<String, Object> Getliliangsuzhicode(@Param("nianling") float nianling,@Param("SumQuality") int SumQuality);

    @Select("select dept_id as deptId,parent_id as parentId,ancestors, dept_name as deptName,organizationcode,type from sys_dept where dept_id  = #{deptid} and status = 0")
    SysDept selectSysDept(@Param("deptid") Long deptid);

    @Select("SELECT testtime,shengaoval,zuogaoval,tizhongval,tzzsval,tzlval,xiongweival,yaoweival,tunweival,fhlval,glcval,lfzydgttval," +
            "lfzydgttzval,lfzydgttyval,ajxlval,wolival,zongtiaoval,fwcval,gwcval,yfzywqzval,zwtqqval,bydjzlval,xzfysval,beilival,ssmzzval," +
            "ldtyval,sjlxtval,swmrzapval,zphmval from ${tablename} where idcard = #{idcard}")
    List<DataApp> selectDataApp(@Param("tablename") String tablename, @Param("idcard") String idcard);

}
